using System;
using FlowCanvas;
using FlowCanvas.Nodes;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.StreetEvent;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    public class SetStreetFightCup : PureFunctionNodeBase
    {
        [HideInInspector]
        public FlowOutput onPlay;
        public void Invoke(PropItem cup)
        {
            if (StreetFightEvent.Instance != null)
            {
                StreetFightEvent.Instance.SetCup(cup);
            }
            onPlay?.Call(new Flow());
        }

        protected override void OnRegisterPorts(FlowNode node)
        {
            var p1 = node.AddValueInput<PropItem>("CupItem");
            node.AddFlowInput(" ", (Flow f) =>
            {
                Invoke(p1.value);
            });

            onPlay = node.AddFlowOutput("Out");
        }
    }
}